// stores/userInfo.js
import { defineStore } from 'pinia';

export const useUserInfoStore = defineStore('userInfo', {
  state: () => ({
    userName: '',
    email: '',
    permission: 0,  // 0 代表普通用户，1 代表 VIP
    registerDate: '',
    records: [],  // 搜索记录
  }),
  actions: {
    setUserInfo(userInfo) {
      this.userName = userInfo.userName;
      this.email = userInfo.email;
      this.permission = userInfo.permission;
      this.registerDate = userInfo.registerDate;
      this.records = userInfo.records;
    },
    updatePermission(permission) {
      this.permission = permission;
    },
    clearUserInfo() {
      this.userName = '';
      this.email = '';
      this.permission = 0;
      this.registerDate = '';
      this.records = [];
    },
  },
});
export default useUserInfoStore;